/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package trivia;


/**
 *
 * @author mourawi
 */
public class Test {

    private Subject subject;

    private int activeProblem;

    private int correctAnswers;

    public Test(Subject subject) {
        this.subject = subject;
        this.activeProblem = 0;
        this.correctAnswers = 0;
    }

    public int getActiveProblemIndex() {
        return activeProblem;
    }

    public Problem getActiveProblem() {
        return subject.getProblem(activeProblem);
    }

    public int getCorrectAnswers() {
        return correctAnswers;
    }

    public void processUserAnswer(int userAnswer) {
        if(subject.getProblem(activeProblem).getCorrect() == userAnswer) {
            correctAnswers++;
        }
    }

    public boolean hasNextProblem() {
        return (activeProblem+1) < subject.getProblemsNumber();
    }

    public void takeNextProblem() {
        activeProblem++;
    }

    public Subject getSubject() {
        return subject;
    }
}
